package io.sxl.modules.generator.controller;

import io.sxl.common.utils.R;
import io.sxl.modules.generator.service.HouseService;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/generator/echarts")
public class EchartsController {

    @Resource
    private HouseService service;

    @GetMapping("/demo1")
    public R demoTest() {
        Map<String, Integer> map = service.queryFenpeidiaobozonglan();

        List<Res> echarts = new ArrayList<>();

        echarts.add(new Res(map.get("finish"), "完成分配"));
        echarts.add(new Res(map.get("half"), "已调拨未分配"));
        echarts.add(new Res(map.get("not"), "未调拨"));

        return new R().put("echarts", echarts);
    }


    @GetMapping("/mainxiaoqu")
    public R mainXiaoqu() {
        return service.mainXiaoqu();
    }

    @Data
    @AllArgsConstructor
    @NoArgsConstructor
    class Res {
        private Integer value;
        private String name;
    }


}
